<?php
include('pclzip.lib.php');

if($_REQUEST['odcms_googlecode'])
{
	$data = @file_get_contents("http://odcms.googlecode.com/files/".$_REQUEST['odcms_googlecode'].".zip");
	$fp = fopen("../odcms_design.zip","w");
	fwrite($fp,$data);
	fclose($fp);

	$archive = new PclZip("../odcms_design.zip");

	if ($archive->extract(PCLZIP_OPT_PATH, "../") == 0)
	{
		echo $_REQUEST['design']." - ".PCLZIP_OPT_PATH, "<br />../designs/$designer/$design/<br /><br />";
		die("Error : ".$archive->errorInfo(true));
	}
	echo $_REQUEST['odcms_googlecode']." extracted!<br />";
	
	exit;
}
list($designer,$design) = explode(".",$_REQUEST['design']);

echo "<h3>archive: ../designs/$designer/$design.zip</h3>";

if(is_dir("../designs/$designer/$design/"))
{
	echo "$designer $design was aready archived";
	exit;
}
mkdir("../designs/$designer/$design/", 0755);

$archive = new PclZip("../designs/$designer/$design.zip");

if ($archive->extract(PCLZIP_OPT_PATH, "../designs/$designer/$design/") == 0)
{
	echo $_REQUEST['design']." - ".PCLZIP_OPT_PATH, "<br />../designs/$designer/$design/<br /><br />";
	die("Error : ".$archive->errorInfo(true));
}
echo "$designer <b>$design</b> extracted ($design.zip)<br />";

?>
